package com.xcity.game.task.detector;

import com.alibaba.fastjson.JSONObject;
import com.xcity.game.employee.config.impl.EmployeeRecruitConfigure;
import com.xcity.game.task.Task;
import com.xcity.game.task.TaskDetector;
import com.xcity.game.task.TaskDetectorLabel;
/**
 * PVE普通通关
 * 1个参数:
 * 1.次数
 * @author shipeng.zhu
 */
@TaskDetectorLabel(TaskDetector.PVE_NORMAL_COUNT)
public class PVENormalTaskDetector implements TaskDetector {
	
	static final String KEY = String.valueOf(PVE_NORMAL_COUNT);

	@Override
	public boolean isFinish(Task task) {
		int n = task.getTemplate().getConditions()[0];
		return task.getArchive().getInteger(KEY) >= n;
	}

	@Override
	public void onArchive(Task task, Object... vals) {
		//{24: 普通通关次数}
		int count = (int) vals[0];
		JSONObject archive = task.getArchive();
		archive.put(KEY, archive.getIntValue(KEY) + count);
	}
}
